﻿using Hopscotch.Common.Logging;
using Microsoft.AspNet.SignalR.Hubs;

namespace Hopscotch.Server.EnqSignalRHost
{
    public class ErrorHandlingPipelineModule : HubPipelineModule
    {
        static readonly ILogger logger = AppLogger.CreateLogger<ErrorHandlingPipelineModule>();

        protected override void OnIncomingError(ExceptionContext ex, IHubIncomingInvokerContext context)
        {
            string msg = string.Format("Error in Hub {0}. {1}", context.MethodDescriptor.Name, ex.Error.Message);
            logger.Error(msg, ex.Error);

            base.OnIncomingError(ex, context);
        }
    }
}
